import request from '@/utils/request'
import { downloadFile } from '@/utils/index'

export function downloadInventory(id) {
  let url = 'drugInventory/downloadDrugForInventory'
  if (id > 0) {
    url += '?drugType=' + id
  }
  request({
    url: url,
    method: 'post',
    responseType: 'blob'
  }).then(result => {
    downloadFile(result, '盘点信息', 'xlsx')
  })
}

export function getDetail(id) {
  return request({
    url: 'drugInventory/detail?id=' + id,
    method: 'get'
  })
}

export function downloadDetail(id) {
  request({
    url: 'drugInventory/downloadInventoryDetail?id=' + id,
    method: 'post',
    responseType: 'blob'
  }).then(result => {
    downloadFile(result, '盘点信息', 'xlsx')
  })
}

export function examine(data) {
  return request({
    url: 'drugInventory/examine',
    method: 'post',
    data
  })
}
